package com.example.app.viewmodel

import androidx.compose.ui.graphics.Color
import androidx.lifecycle.ViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update

class BarStateViewModel(mainViewModel: MainViewModel) : ViewModel() {
    //顶部任务栏字体颜色
    var _statusBarDarkIcon = MutableStateFlow(false)
    var statusBarDarkIcon = _statusBarDarkIcon.asStateFlow()
    fun flowUpdate_statusBarDarkIcon(value: Boolean) {
        _statusBarDarkIcon.update { value }
    }
    //顶部状态栏颜色
    var _statusBarColor = MutableStateFlow(Color.Transparent)
    var statusBarColor = _statusBarColor.asStateFlow()
    fun flowUpdate_statusBarColor(value: Color) {
        _statusBarColor.update { value }
    }
    //底部导航栏字体颜色
    var _navigationBarDarkIcon = MutableStateFlow(false)
    var navigationBarDarkIcon = _navigationBarDarkIcon.asStateFlow()
    fun flowUpdate_navigationBarDarkIcon(value: Boolean) {
        _navigationBarDarkIcon.update { value }
    }
    //底部导航栏颜色
    var _navigationBarColor = MutableStateFlow(Color.Transparent)
    var navigationBarColor = _navigationBarColor.asStateFlow()
    fun flowUpdate_navigationBarColor(value: Color) {
        _navigationBarColor.update { value }
    }
    //底部导航栏控制
    var _showBottomBar = MutableStateFlow(false)
    var showBottomBar = _showBottomBar.asStateFlow()
    fun flowUpdate_showBottomBar(value: Boolean) {
        _showBottomBar.update { value }
    }

    fun updateAll(
            isStatusBarDarkIcon: Boolean,
            isNavigationBarDarkIcon: Boolean,
            statusBarColor: Color,
            navigationBarColor: Color,
            isShowBottomBar: Boolean) {
        flowUpdate_statusBarDarkIcon(isStatusBarDarkIcon)
        flowUpdate_showBottomBar(isShowBottomBar)
        flowUpdate_statusBarColor(statusBarColor)
        flowUpdate_navigationBarColor(navigationBarColor)
        flowUpdate_navigationBarDarkIcon(isNavigationBarDarkIcon)
    }
}